var myApp = angular.module("myApp",["ui.router", "angularFileUpload", 'ngCookies']);

myApp.config(function($stateProvider, $urlRouterProvider, $httpProvider){
	$httpProvider.defaults.withCredentials = true;
	$urlRouterProvider.otherwise("/login");
	$stateProvider
		.state("/login", {
			url: "/login",
			controller: 'signinCtrl',
			templateUrl: "./tpls/login.html"
		}).state("/register", {
			url: "/register",
			controller: "registerCtrl",
			templateUrl: "./tpls/register.html"
		});

	$stateProvider
		.state("/", {
			url: "/",
			views: {
				"": { templateUrl: "./tpls/public/body.html" },
				"header@/": { templateUrl: "./tpls/public/header.html" },
				"main@/": { templateUrl: "./tpls/public/main.html" },
				"left@/": { templateUrl: "./tpls/public/left.html" },
				"center@/": { templateUrl: "./tpls/public/center_user.html" },
				"right@/": { templateUrl: "./tpls/public/right.html" }
			}
		}).state("/.user", {
			url: "user/info",
			controller: "userCtrl",
			views: {
				"right@/": { templateUrl: "./tpls/user/info.html" }
			}
		}).state("/.head_img", {
			url: "user/head_img",
			controller: "uploaderCtrl",
			views: {
				"right@/": { templateUrl: "./tpls/user/head_img.html" }
			}
		}).state("/.passwd", {
			url: "user/passwd",
			views: {
				"right@/": { templateUrl: "./tpls/user/passwd.html" }
			}
		}).state("/.list", {
			url: "user/list",
			views: {
				"right@/": { templateUrl: "./tpls/user/list.html" }
			}
		}).state("/.group", {
			url: "user/group",
			views: {
				"right@/": { templateUrl: "./tpls/user/group_add.html" }
			}
		}).state("/.role", {
			url: "user/role",
			views: {
				"right@/": { templateUrl: "./tpls/user/role.html" }
			}
		}).state("/.token", {
			url: "user/token",
			views: {
				"right@/": { templateUrl: "./tpls/user/token.html" }
			}
		});

	$stateProvider
		.state("/admin", {
			url: "/admin",
			views: {
				"": { templateUrl: "./tpls/public/body.html" },
				"header@/admin": { templateUrl: "./tpls/public/header.html" },
				"main@/admin": { templateUrl: "./tpls/public/main.html" },
				"left@/admin": { templateUrl: "./tpls/public/left.html" },
				"center@/admin": { templateUrl: "./tpls/public/center_admin.html" },
				"right@/admin": { templateUrl: "./tpls/public/right.html" }
			}
		}).state("/admin.role_manage", {
			url: "/role",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/role_add.html" }
			}
		}).state("/admin.role_list", {
			url: "/role/list",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/role_list.html" }
			}
		}).state("/admin.role_sm", {
			url: "/role/review/:id",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/role_sm.html" }
			}
		}).state("/admin.group_manage", {
			url: "/group",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/group_add.html" }
			}
		}).state("/admin.group_list", {
			url: "/group/list",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/group_list.html" }
			}
		}).state("/admin.group_sm", {
			url: "/group/review/:id",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/group_sm.html" }
			}
		}).state("/admin.privilege_manage", {
			url: "/privilege",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/privilege_add.html" }
			}
		}).state("/admin.privilege_list", {
			url: "/privilege/list",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/privilege_list.html" }
			}
		}).state("/admin.privilege_sm", {
			url: "/privilege/review/:id",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/privilege_sm.html" }
			}
		}).state("/admin.user_list", {
			url: "/user/list",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/user_list.html" }
			}
		}).state("/admin.user_manage", {
			url: "/user",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/user_add.html" }
			}
		}).state("/admin.user_sm", {
			url: "/user/review/:id",
			views: {
				"right@/admin": { templateUrl: "./tpls/admin/user_sm.html" }
			}
		});
});